export default class extends think.BaseController {
  /**
     * @description 获取标识信息
     */
  async getOperationAction() {
    const OperationService = this.service('sys/OperationService');
    const getData = this.get('page,pageSize,name,code');
    const res = await OperationService.getOperation(getData);
    if (res && res.error) {
      return this.errorJson('查询失败');
    } else {
      return this.successJson(res);
    }
  }
  /**
   * @description 获取所有权限标识
   */
  async saveOperationAction() {
    const OperationService = this.service('sys/OperationService');
    const postData = this.post('id,name,code,color,icon');
    const res = await OperationService.upDataOperation(postData);
    if (res && res.error) {
      return this.errorJson(res.error);
    } else {
      return this.successJson(res);
    }
  }

  /**
   * @description 删除权限标识
   */
  async delOperationAction() {
    const OperationService = this.service('sys/OperationService');
    const PostData = {
      id: this.post('id')
    };
    const res = await OperationService.delOperation(PostData);
    if (res && res.error) {
      return this.errorJson(res.error);
    } else {
      return this.successJson(res);
    }
  }

  /**
   * @description 获取所有权限标识
   */
  async getOperationAllAction() {
    const OperationService = this.service('sys/OperationService');
    const res = await OperationService.getOperationAll();
    if (res && res.error) {
      return this.errorJson('查询失败');
    } else {
      return this.successJson(res);
    }
  }
}
